package com.itrip.itripauth.service.impl;

import com.itrip.itripauth.entity.HotelTempStore;
import com.itrip.itripauth.mapper.HotelTempStoreMapper;
import com.itrip.itripauth.service.HotelTempStoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itrip.itripauth.vo.AddOrderVo;
import com.itrip.itripauth.vo.RoomStoreVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 实时库存表 服务实现类
 * </p>
 *
 * @author 四阶段项目二组
 * @since 2020-02-25
 */
@Service
public class HotelTempStoreServiceImpl extends ServiceImpl<HotelTempStoreMapper, HotelTempStore> implements HotelTempStoreService {
    @Resource
    private HotelTempStoreMapper hotelTempStoreMapper;
    @Override
    public RoomStoreVO getPreorderInfo(AddOrderVo addOrderVo) {
        Integer roomCount = hotelTempStoreMapper.getRoomCount(addOrderVo);
        RoomStoreVO roomStoreVO = new RoomStoreVO();
        if(roomCount!=null && roomCount>0 ){
            roomStoreVO = hotelTempStoreMapper.getPreorderInfo(addOrderVo);
            roomStoreVO.setCount(addOrderVo.getCount());
            roomStoreVO.setStore(roomCount);
        }
        return roomStoreVO;
    }
}
